<?php
namespace App\Api\Transformers;

use App\Club;
use League\Fractal\TransformerAbstract;

/**
 * Class ClubInfoTransformer
 * @package App\Api\Transformers
 */
class ClubInfoTransformer extends TransformerAbstract
{
    /**
     * @var array
     */
     protected $availableIncludes  = [
        'coaches',
    ];

    /**
     * @param Club $clubInfo
     * @return array
     */
    public function transform(Club $clubInfo)
    {
        $picUrl = "http://yuejian.app/uploads/clubs_pic/clubs/";
        return [
            'club_id' => $clubInfo['id'],
            'club_name' => $clubInfo['club_name'],
            'club_pic' => $picUrl.$clubInfo['club_pic'],
            'club_intro' => $clubInfo['club_intro'],
            'club_address' => $clubInfo['club_address'],
            'club_phone' => $clubInfo['club_phone'],
            'work_time' => $clubInfo['work_time'],
            'coach_count' => $clubInfo['coach_count'],
            'coaches' => isset($clubInfo->coaches) ? $clubInfo->coaches : 'NUll'
        ];
    }
}